package nl.wubinator.aeve.xmlconverters.standard.parsers;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import org.xml.sax.Attributes;

import android.util.Log;

import nl.wubinator.aeve.models.standard.alliancelist.Corporation;

public class CorporationParser {

	public static Corporation parseAttributes(Attributes atts) {
		Corporation corporation = new Corporation();
		try {
			DateFormat dateFormatter = new SimpleDateFormat(
					"yyyy/dd/mm HH:mm:ss");
			// The character consists of the following attributes:
			// - corporationID
			// - startDate
			corporation.setCorporationID(Integer.parseInt(atts
					.getValue("corporationID")));
			corporation.setStartDate(dateFormatter.parse(atts
					.getValue("startDate")));
		} catch (ParseException e) {
			Log.e("Parsing date failed:", e.getMessage());
		}
		
		return corporation;
	}
}
